package com.yb.domain.goods;

// default package

import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.yb.base.annotation.Column;
import com.yb.base.annotation.Table;
import com.yb.base.entity.BaseEntity;

/**
 * TgInformation entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@Table("t_g_information")
public class TgInformation extends BaseEntity implements java.io.Serializable {

	// Fields

	private String title;

	private String content;

	private Date createDate;

	private String hot;

	private Integer categoryId;

	private Integer pcategoryId;

	private Integer brandId;

	private String imgFlag;

	private String imgUrl;

	private String hotActivities;

	private String the1;

	private String the2;
	
	private Integer isRecommend;
	
	private Integer messageId;
	
	@Column(name = "reject")
	private String creatTimeStr;

	@Column(name = "reject")
	private String contentShort;

	@Column(name = "reject")
	private String contentDesc;

	private Integer weights;
	
	private String creator;
	
	private Integer categoryFlag;
	
	public String getContentShort() {
		if (null != title) {
			contentShort = getContentShort1(title);
			if ("".equals(contentShort))
				contentShort = the1+the2;
		}
		return contentShort;
	}

	public void setContentShort(String contentShort) {
		this.contentShort = contentShort;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getHot() {
		return this.hot;
	}

	public void setHot(String hot) {
		this.hot = hot;
	}

	public Integer getBrandId() {
		return this.brandId;
	}

	public void setBrandId(Integer brandId) {
		this.brandId = brandId;
	}

	public Integer getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}

	public Integer getPcategoryId() {
		return pcategoryId;
	}

	public void setPcategoryId(Integer pcategoryId) {
		this.pcategoryId = pcategoryId;
	}

	public String getImgFlag() {
		return imgFlag;
	}

	public void setImgFlag(String imgFlag) {
		this.imgFlag = imgFlag;
	}

	public String getImgUrl() {
		return imgUrl;
	}

	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}

	public String getHotActivities() {
		return hotActivities;
	}

	public void setHotActivities(String hotActivities) {
		this.hotActivities = hotActivities;
	}

	public String getCreatTimeStr() {
		return creatTimeStr;
	}

	public void setCreatTimeStr(String creatTimeStr) {
		this.creatTimeStr = creatTimeStr;
	}

	public String getThe1() {
		return the1;
	}

	public void setThe1(String the1) {
		this.the1 = the1;
	}

	public String getThe2() {
		return the2;
	}

	public void setThe2(String the2) {
		this.the2 = the2;
	}

	public String getContentDesc() {
		if (null != content) {
			contentDesc = getShortDesc(content);
			if ("".equals(contentDesc))
				contentDesc = the1+the2;
		}
		if (null != contentDesc)
			if (contentDesc.length() > 50)
				contentDesc = contentDesc.substring(0, 50) + "...";
		return contentDesc;
	}

	private String getShortDesc(String str) {
		String temp = "";
		Pattern patt = Pattern.compile(">[*[^<]]+<");
		Matcher m = patt.matcher(content);
		while (m.find()) {
			String contentDesc = "";
			contentDesc = m.group(0);
			contentDesc = contentDesc.substring(1, contentDesc.length() - 1);
			contentDesc = contentDesc.replaceAll("\\r", "").replaceAll("\\n",
					"").replaceAll("\\t", "").replaceAll(" ", "").replaceAll(
					"&nbsp;", "");
			temp += contentDesc;
			if (temp.length() >= 50)
				break;
		}
		return temp;
	}

	private String getContentShort1(String str) {
		String temp = "";
		Pattern patt = Pattern.compile(">[*[^<]]+<");
		Matcher m = patt.matcher(title);
		boolean flag = false;
		while (m.find()) {
			flag = true;
			String contentDesc = "";
			contentDesc = m.group(0);
			contentDesc = contentDesc.substring(1, contentDesc.length() - 1);
			contentDesc = contentDesc.replaceAll("\\r", "").replaceAll("\\n",
					"").replaceAll("\\t", "").replaceAll(" ", "").replaceAll(
					"&nbsp;", "");
			temp += contentDesc;
		}
		if(!flag)
			temp = title;
		return temp;
	}
	
	public void setContentDesc(String contentDesc) {
		this.contentDesc = contentDesc;
	}

    public Integer getIsRecommend() {
        return isRecommend;
    }

    public void setIsRecommend(Integer isRecommend) {
        this.isRecommend = isRecommend;
    }

    public Integer getMessageId() {
        return messageId;
    }

    public void setMessageId(Integer messageId) {
        this.messageId = messageId;
    }

    public Integer getWeights() {
        return weights;
    }

    public void setWeights(Integer weights) {
        this.weights = weights;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public Integer getCategoryFlag() {
        return categoryFlag;
    }

    public void setCategoryFlag(Integer categoryFlag) {
        this.categoryFlag = categoryFlag;
    }
    
    

}